<?php 


$wx=new wxGet();

// $a = php_sapi_name();
// var_dump($a);

$token=$wx->getToken('wx258fd99a593928a8','7fa269ca869c067cfe6aa96ea49c24cf'); //小美的


//$token=$wx->getToken('wx678f00bfc6c63974','8aea10154f91fb9cc40f282799744552'); //曲美的
// $token=$wx->getToken('wx865deb1a17f23804','e51f4c1ec21e87c01ab7fdbb2d2ffaab'); //测试的

$openid='oW2Wk1VNG0-mJUbKvMphScwmdTNU';

$userinfo=$wx->getDate('cgi-bin/user/info',['openid'=>$openid,'lang'=>'zh_CN','access_token'=>$token]);  //通过oppenid获取用户信息

// $userinfoList=$wx->getDate('cgi-bin/user/get',['access_token'=>$token]); //获取用户微信openid

// $auto=$wx->getDate('cgi-bin/get_current_autoreply_info',['access_token'=>$token]);

// $jsapi_ticket=$wx->getDate('cgi-bin/ticket/getticket',['access_token'=>$token,'type'=>'jsapi']);


//$jsonMean=file_get_contents('maen.json');

//$ameun=json_decode($jsonMean,true);


//$mune=$wx->getDate('cgi-bin/get_current_selfmenu_info',['access_token'=>$token]); //获取微信公众号菜单

//$setmuen=$wx->php_do_url_POST('https://api.weixin.qq.com/cgi-bin/menu/create?access_token='.$token,json_encode($ameun['selfmenu_info'],JSON_UNESCAPED_UNICODE));

//$remark=$wx->php_do_url_POST('https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token='.$token,['openid'=>'oW2Wk1VKXTpczoie9Owr8o0bu8XQ','remark'=>'赵怀帅']);

echo '<pre>';
        
   var_dump($userinfo);

    //var_dump($userinfoList);

    //var_dump($mune);

    //file_put_contents('maen.json', json_encode($mune,JSON_UNESCAPED_UNICODE)) ;
    // var_dump($ameun['selfmenu_info']);
    // var_dump($setmuen);

    //var_dump($jsapi_ticket);

echo '</pre>';

// $remark=$wx->php_do_url_POST('https://api.yunque360.com/v1/company/conversation/wechat-history',['open_id'=>'ohA_w00SRd2nMhzfKy5Menn64jJg']);

// var_dump($remark);

class wxGet{



    public function getToken($appid,$secret){

        $params=['grant_type'=>'client_credential','appid'=>$appid,'secret'=>$secret];

        $access_token=self::php_do_Url_GET('https://api.weixin.qq.com/cgi-bin/token',$params)['access_token'];

        return $access_token;

    }

    public function getDate($api,$params){

       return self::php_do_Url_GET('https://api.weixin.qq.com/'.$api,$params);

    }


    public function  php_do_url_POST($url,$params,$headers=[]){ //POST get

        $ch = curl_init ();
        curl_setopt ( $ch, CURLOPT_URL, $url );
        curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
        curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, 'POST' );
        curl_setopt ( $ch, CURLOPT_POSTFIELDS, $params );
        curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
        curl_setopt ( $ch, CURLOPT_TIMEOUT, 60 );
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_SSLVERSION, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        $json_string = curl_exec ( $ch );
        $data = json_decode($json_string, true);
        curl_close ( $ch );
        return $data;
    }

    public function php_do_Url_GET($url,$params){ //Get get

        $url = "{$url}?" . http_build_query ($params);
        $ch = curl_init ();
        curl_setopt ( $ch, CURLOPT_URL, $url );
        curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
        curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, 'GET' );
        curl_setopt ( $ch, CURLOPT_TIMEOUT, 60 );
        curl_setopt ( $ch, CURLOPT_POSTFIELDS, $params );
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_SSLVERSION, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);    

        $json_string = curl_exec ( $ch );

        $data = json_decode($json_string, true);

        curl_close ( $ch );

        return $data;
    }


}



 ?>
